package com.heima.algorithm.recursion;

/**
 * 阶乘递归
 */

public class Factorial {
    public static int factorial(int n){
        if (n == 1 || n == 0){
            return 1;
        }
        return n * factorial(n - 1);
    }

    public static void main(String[] args) {
        System.out.println("0! = " + Factorial.factorial(0));
        System.out.println("1! = " + Factorial.factorial(1));
        System.out.println("8! = " + Factorial.factorial(8));
    }
}
